/**
 * 寄生组合继承
 * 
 */


// function interface (son,father) {
//   let clone = Object.create(father.prototype)
//   clone.contructor = son
//   son.prototype = clone
// }

// function Father (name) {
//   this.name = name
//   this.cars = ['保时捷','宾利','兰博基尼']
// }

// Father.prototype.sayName = function(){
//   console.log(this.name)
// }

// function Son (name,age){
//   Father.call(this, name)
//   this.age = age
// }
// interface(Son,Father)

// Son.prototype.sayAge=function(){
//   console.log(this.age)
// }

// let mySon = new Son('lu-lu',20)
// mySon.cars.push('lulu')
// console.log(mySon.cars)
// mySon.sayName()
// mySon.sayAge()


// let mySon2 = new Son('lucy',60)
// mySon2.cars.push('林肯')
// console.log(mySon2.cars)
// mySon2.sayName()
// mySon2.sayAge()

function zuhe (sub,supe) {
  console.log(supe.prototype)
  let cloneO = Object.create(supe.prototype)
  cloneO.constructor = sub
  console.log(cloneO)
  sub.prototype = cloneO
}

function SuperClass (name) {
  this.name = name
}

SuperClass.prototype.sayName=function() {
  console.log(`名字是==== ${this.name}`)
}

function SubClass (name, age) {
  SuperClass.call(this, name)
  this.age = age
}

zuhe(SubClass, SuperClass)

SubClass.prototype.sayAge = function () {
  console.log(`this age ===${this.age}`)
}

let p1 = new SubClass('lu-lu',20)

p1.sayAge()
p1.sayName()